#include <iostream>
#include <vector>
#include <algorithm>

class EelAndRabbit {
	struct Eel{
		int head;
		int tail;
		bool catched;
	};
	struct EelComp {
		bool operator()(const Eel & lhs, const Eel& rhs) {
			return lhs.head < rhs.head;
		}
	};
public:
	int getmax(std::vector <int> l, std::vector <int> t);
};

int EelAndRabbit::getmax(std::vector <int> l, std::vector <int> t) {
	std::vector<Eel> eels(l.size());
	for (int i = 0; i< eels.size(); ++i) {
		eels[i].head = t[i];
		eels[i].tail = t[i] + l[i];
		eels[i].catched = false;
	}
	int max = 0;
	std::sort(eels.begin(), eels.end(), EelComp());
	if (eels.size() == 1)
		return 1;
	for (int i = 0; i < eels.size()-1; ++i) {
		for ( int k = i+1; k < eels.size(); ++k) {
			int count = 0;
			for (int j = 0; j <=i; ++j) {
				if ( eels[i].head <= eels[j].tail) {
					++count;
					eels[j].catched = true;
				}
			}
			for (int j = 0; j <= k; ++j) {
				if ( eels[k].head <= eels[j].tail && eels[j].catched == false )
					++count;
			}
			max = std::max(max, count);
			for (int j = 0; j <= i; ++j) 
				eels[j].catched = false;
		}
	}
	return max;
}

void test_srm580_250_internal(int * la, int * ta, int n) {
	std::vector<int> lv(la, la+n);
	std::vector<int> tv(ta, ta+n);

	EelAndRabbit ear;
	std::cout << "max: " << ear.getmax(lv, tv) << std::endl;
}

void test_srm580_250() {
	int l0[] = {2, 4, 3, 2, 2, 1, 10};
	int t0[] = {2, 6, 3, 7, 0, 2, 0};
	test_srm580_250_internal(l0, t0, sizeof(l0)/sizeof(int));

	int l1[] = {1, 1, 1};
	int t1[] = {2, 0, 4};
	test_srm580_250_internal(l1, t1, sizeof(l1)/sizeof(int));

	int l2[] = {1};
	int t2[] = {1};
	test_srm580_250_internal(l2, t2, sizeof(l2)/sizeof(int));

	int l3[] = {8, 2, 1, 10, 8, 6, 3, 1, 2, 5};
	int t3[] = {17, 27, 26, 11, 1, 27, 23, 12, 11, 13};
	test_srm580_250_internal(l3, t3, sizeof(l3)/sizeof(int));
}